function SupplierSelect_Code(flag) {
	var buffer = new StringBuffer();
	buffer.append('<div id="find2" class="finds2" flag="'+flag+'" style="z-index:100;"><div class="searchinput ui-border-radius"><input id="keyword2" class="bordersolid" type="text" value="" onblur="Show_Search2()" onkeyup="SupplierSelect_Search();"/><div id="searchicon2" class="searchicon"><img src="img/jing.jpg"/></div><div id="searchicons2" class="searchicons"><img src="img/jings.jpg"/></div></div></div>');
	buffer.append('<div class="horizen border-bottom" style="z-index:100;"></div>');
	return buffer.toString();
};

function SupplierSelect_Data(data) {
	var buffer = new StringBuffer();
	$(data).each(function(i,info){
		buffer.append('<div class="productlist border-bottom" id="'+info.ID+'" ><div class="productname">'+info.Name+'</div><div class="productinfo"><div class="price">联系人：'+info.ContactName.ToString()+'</div><div class="createdate">'+info.CreateDate.ToTime()+'</div></div></div>');
	});
	return buffer.toString();
};

function Receive_SupplierSelect(pageindex)
{
	var data = {};
			data.act = "Find_Supplier";
			data.userid=userid;
			data.comid=comid;
			data.pageindex=pageindex;
			data.source=source;
			data.pagesize=PAGE_SIZE20;
			data.keyword = $("#keyword2").val();
		    data.timer = "";
		    data.state = "";
		    data.type = 1;
		    data.lowers = "";
		    data.sign=GetSign(data.act);
			
			mui.getJSON(crm_domain, data, function(json) {
				if(json.data.list.length>0)
				{
					if(pageindex==1)
					{
						$("#contentlist4").html(SupplierSelect_Data(json.data.list));
					}else{
						$("#contentlist4").append(SupplierSelect_Data(json.data.list));
					}
					setTimeout(function(){
						Init_SupplierSelect();
						myScroll3.refresh();
					},500); //需要延迟500毫秒加载，否则当数量少时不能下拉
					if(json.data.list.length!=data.pagesize)
					{
						$("#loading4").html("");
					}else{
						$("#loading4").html('<img src="img/loading.gif"/>');
					}
				}else
				{
					if(pageindex==1)
					{
						$("#contentlist4").html("");
						$("#loading4").html("主人，没有找到您需要的数据"); 
					}else
					{
						$("#loading4").html("没有更多了");
					}
				}
				
         		pageindex = parseInt($("#divmsg4").attr("pageindex"))+1;
         		$("#divmsg4").attr("pageindex",pageindex);
         		
         		
			});
};

function SupplierSelect_Search(){
	Receive_SupplierSelect(1);
};




function Init_SupplierSelect()
{
	mui("#contentlist4").off("tap",".productlist");
	mui("#contentlist4").on("tap",".productlist",function(){
		$("#product_tool font").hide();
		$("#product_tool table").removeClass("hidden");
		$("#txt_supplierid").val($(this).find(".productname").html());
		$("#txt_supplierid").attr("supplierid",$(this).attr("id"));
		CloseWindow();
	});
};


//删除一项订单产品
function Delete_SupplierDetail(o) {
    $(o).parent().parent().remove();
};